因為取資料的方式都以時間線的方式取得(http, websocket)
所以時區是一個必須要解決的問題
在 Mongodb 中 Date 儲存的是 Int
沒有辦法在 Storage 層中解決時區問題
所以在儲存的時候都統一使用 UTC
所以在處理時區問題可以在 getter/setter 中解決
以getter 做範例
const DEFAULT_TIME_ZONE = 'Asia/Taipei';
const DEFAULT_FORMAT_DATE_TIME = 'yyyy-MM-dd HH:mm:ss.SSS';
const schemaOptions = {
  toObject: {
    getters: true,
    virtuals: true,
    versionKey: false,
    transform: function(doc, ret) {
      ret.id = ret._id;
      delete ret._id;
    }
  },
  toJSON: {
    getters: true,
    virtuals: true,
    versionKey: false,
    transform: function(doc, ret) {
      ret.id = ret._id;
      delete ret._id;
    }
  },
  runSettersOnQuery: true,
};
const formatDateTime = (date) =>
  format(utcToZonedTime(date, DEFAULT_TIME_ZONE), DEFAULT_FORMAT_DATE_TIME);
const messageSchema = new Schema({
  createAt: {
    type: Date,
    default: now,
    get: formatDateTime,
  },
}, schemaOptions);
這樣取值的時候會自動將 UTC 轉為 Asiz/Taipei 的時區時間
再順便處理 format
而在 schemaOptions 中部只處理 getter/setter
同時將 _id => id 做處理